package cn.net.yugu.doraemon.common.arms;

import com.alibaba.arms.sdk.v1.async.Objects;
import com.alibaba.arms.sdk.v1.async.TraceExecutors;
import com.alibaba.arms.sdk.v1.async.wrapper.CommandWrapper;
import com.alibaba.arms.sdk.v1.async.wrapper.DefaultCommandWrapper;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

/**
 * @author xiangzhurui
 * @version 2023/8/11 22:17:30
 */
public class ArmsTraceExecutors extends TraceExecutors {

  public static ThreadPoolTaskExecutor wrapThreadPoolTaskExecutor(ThreadPoolTaskExecutor taskExecutor) {
    Objects.requireNonNull(taskExecutor, "taskExecutor");

    CommandWrapper wrapper = newCommandWrapper();
    return new TraceThreadPoolTaskExecutor(taskExecutor, wrapper);
  }

  private static CommandWrapper newCommandWrapper() {
    return new DefaultCommandWrapper();
  }

}
